/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.iprojectmanager.views;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
//import com.iprojectmanager.managers.*;
import com.iprojectmanager.entities.*;
import com.iprojectmanager.managers.*;
//import java.util.Enumeration;

/**
 *
 * @author Enrique
 */
public class VistaArchivo extends Vista{
   
    
    public void mainView(PrintWriter out,IntegranteProyecto user,String act) throws ServletException, IOException
    {
        ActivitiesManager manager = new ActivitiesManager();
        Actividad actividad = manager.getActividad(Integer.valueOf(act));
        
            out.println(Utilities.getDocType());
            out.println("<HTML>" + Utilities.getHead("Enviar Avance"));
            out.println("<div id=\"container\">");
            out.println(Utilities.getIntro("Integrante del Proyecto : " + user.getProyecto().getNombre() + " <br> " +
                                            "Avance de la Actividad: " + actividad.getNombre(),user));
            String content = "<div id=\"pageContent\">"+
                   "<div id=\"selection1\">"+"</div>"+
                   this.getFormActivities(user) +
                   Utilities.getFooter() + "</div>";
            out.println(content);
            out.println(Utilities.getMenu());
            out.println("</div> <!-- fin container --> </BODY></HTML>");
    }
    
    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
        PrintWriter out = response.getWriter();
        HttpSession user = request.getSession();
        String actividad = request.getParameter("actividades");
        request.getSession().setAttribute("actividad", new String(actividad));
        IntegranteProyecto enviador = (IntegranteProyecto)user.getAttribute("user");
        response.setContentType("text/html");
        mainView(out,enviador,actividad);
    }
    
    @Override
    public String getServletInfo(){
        return "Vista Enviar Avance";
    }
    
    public String getFormActivities(IntegranteProyecto user){
        //ActivitiesManager manager = new ActivitiesManager();
        return "<h3><span>Enviar Archivo</span></h3>"+
                "<p class=\"p1\"><span>"+
                "<form action=\"FileManager\" enctype=\"multipart/form-data\" method=\"POST\">"+
                "<label>Archivo a Enviar:</label><input type=\"file\" name=\"file\"></input><br></br>"+
                "<button type=\"submit\">Enviar</button>"+
                "</form>"+
                "</span></p>";        
    }
}
